<template>
    <BasicTable ref="tableRef" :params="params" :columns="columns" :memory="true" box-type="radio" :query="queryValidUser" @select-change="onSelectChange">
        <template #form>
            <a-form-item label="用户名" name="username">
                <a-input v-model:value="params.username" placeholder="请输入用户名" />
            </a-form-item>
            <a-form-item label="手机号" name="phone">
                <a-input v-model:value="params.phone" placeholder="请输入手机号" />
            </a-form-item>
        </template>
    </BasicTable>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { BasicTable } from '@iframe/tools/components'
import { queryValidUser } from '/@/api/System/User'

const tableRef = ref()
const params = reactive({})
const select = reactive({
    selectList: []
})
const columns = [
    {
        title: '用户名',
        dataIndex: 'username',
        key: 'username'
    },
    {
        title: '姓名',
        dataIndex: 'realname',
        key: 'realname'
    },
    {
        title: '工号',
        dataIndex: 'workNo',
        key: 'workNo'
    },
    {
        title: '手机号',
        dataIndex: 'phone',
        key: 'phone'
    }
]
const onSelectChange = (selectedRowKeys, selectedRows) => {
    select.selectList = selectedRows
}
const getSelectList = () => {
    return select.selectList
}
const setSelectKeys = keys => {
    tableRef.value.setSelectedKeys(keys)
}
defineExpose({ getSelectList, setSelectKeys })
</script>
